FC = mpif90

OPTFLAGS = -O3
DEBUGFLAGS =
FCFLAGS = $(OPTFLAGS) $(DEBUGFLAGS) $(F90FLAGS) -warn all

LFLAGS = -lm
LDFLAGS  = $(LFLAGS) $(LINK_MPIS) -mcmodel medium -shared-intel
OTHERFLAGS = $(IFLAGS)

SOURCES = nrtype.f90 nrutil.f90 binom.f90 grid.f90 grid_interpolation.f90 parameters.f90 parameters_energy.f90\
functions.f90 \
randu.f90 rouwenhorst.f90 spline_linear_val.f90 lambda0_optimizer.f90 retired_valuer.f90 cev_finder.f90\
working_valuer.f90 hetero_ss.f90

OBJECTS = $(SOURCES:.f90=.o)
EXEC = cap

%.o: %.f90
	$(FC) $(FCFLAGS) -c $<

all: $(EXEC)

$(EXEC):$(OBJECTS)
	$(FC) $(FCFLAGS) -o $(EXEC) $(OBJECTS) $(LDFLAGS)

clean:
	-$(RM) $(OBJECTS) $(EXEC) *.mod
